package org.example.boot.usercenter.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import org.example.boot.usercenter.common.BaseResponse;
import org.example.boot.usercenter.common.ErrorCode;
import org.example.boot.usercenter.common.ResultUtils;
import org.example.boot.usercenter.exception.BusinessException;
import org.example.boot.usercenter.model.request.PageRequest;
import org.example.boot.usercenter.model.vo.ProductViewVo;
import org.example.boot.usercenter.service.ProductService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @InterfaceName: ProductController
 * @Description:
 * @Author: YourName
 * @Date: 2025/3/19
 */
@RequestMapping("/product")
@RestController
@Api(tags = "商品管理模块")
public class ProductController {
    @Resource
    ProductService productService;

    @GetMapping("/index")
    @Operation(summary = "分页查询商品展示出来", description = "展示查询商品视图详细信息")
    public BaseResponse<List<ProductViewVo>> getProducts(PageRequest pageRequest){
        if(pageRequest == null){
            throw new BusinessException(ErrorCode.PARAMS_ERROR);
        }
        List<ProductViewVo> result = productService.getListProducts(pageRequest);
        return ResultUtils.success(result);
    }

    @GetMapping("{/searchName}")
    @Operation(summary = "根据商品的名字搜索商品", description = "通过商品名字查询商品视图详细信息")
    public BaseResponse<List<ProductViewVo>> searchProductsFromName(
            @Parameter(description = "商品名字", required = true, example = "旺仔牛奶")
            @PathVariable String searchName) {
        return null;
    }

    @GetMapping("{/searchPlace}")
    @Operation(summary = "根据商品的地标搜索商品", description = "通过商品地标查询商品视图详细信息")
    public BaseResponse<List<ProductViewVo>> searchProductsFromPlace(
            @Parameter(description = "地标", required = true, example = "广州")
            @PathVariable String searchPlace) {
        return null;
    }

    @GetMapping("{/getProductId}")
    @Operation(summary = "根据商品Id获取详细的商品信息", description = "通过商品ID查询商品详细信息")
    public BaseResponse<List<ProductViewVo>> getProducts(
            @Parameter(description = "商品ID", required = true, example = "1")
            @PathVariable String getProductId) {
        return null;
    }




}
